//
//  TopBottomView.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/22.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "TopBottomView.h"

typedef void(^HBHMainIconBlcok)(NSInteger);

@implementation TopBottomView
{
    NSInteger _index;
    HBHMainIconBlcok _complete;
}
- (instancetype)initWithFrame:(CGRect)frame data:(NSArray *)data index:(NSInteger)index HangNumber:(NSInteger)number Height:(float)heigthFloat complete:(void(^)(NSInteger index))complete
{
    self = [super initWithFrame:frame];
    if (self) {
        self.frame = CGRectMake(frame.origin.x, frame.origin.y, SCREENW/number, 57*screenW_6);
        _index = index;
        if (complete) {
            _complete = complete;
        }
        
        UILabel *titleLabel = [TomamaUI createLabel:CGRectMake(0,0, self.frame.size.width, 12*screenW_6) textAligment:1 font:[UIFont systemFontOfSize:12*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:data[0]];
        [self addSubview:titleLabel];
        
        UIImageView *icon = [TomamaUI createImageView:CGRectMake(0, 0, 40*screenW_6, 40*screenW_6) backGroundImageV:@""];
        [self addSubview:icon];
        icon.image = [UIImage imageNamed:data[1]];
        icon.frame = CGRectMake(0, 10*screenW_6, icon.image.size.width*0.8, icon.image.size.height*0.8);
        icon.center = CGPointMake(self.frame.size.width/2, self.center.y+heigthFloat);
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click)];
        [self addGestureRecognizer:tap];
    }
    return self;
}

-(void)click
{
    _complete(_index);
}

@end
